unit connections;

//?callback functions for once every iteration of the main loop and allow call back function to change inputs at a specific line.?

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;
Const
  MAGIC=$BADBEEF;
type
(*TTagsList = class
   private
   public
     TagList : TList;
     { Public declarations }
     constructor Create;
     Destructor  Destroy; override;
 end;*)

 TInputs = array of array of single;
 TInputNames = array of string; // names of the inputs to which these inputs belong
 TSignal = class(TObject)
 private
   signal_value : single; //Stored value of signal used for post simulation step storage of signals
 public
   id:string; //id of this entity
   weight: integer;
   source :integer;  //source from neuron number "source"
   external_source:integer;  //external source signal number (only one source at a time is allowed)
   destination: integer;
   tracked:boolean;
   constructor create (_id:string; //id of this entity
                       _weight: integer;
                       _source :integer;  //source from neuron number "source"
                       _destination: integer;
                       _tracked:boolean);
   function toString:string;
 end;
 TPsigmoidunit = ^Tsigmoidunit;
 Tsigmoidunit = class(TObject)
 private
 public
   magic_nr:integer;
   id:integer; //id of this entity
   inputdata: real;
   //threshold:integer; //source
   leak:integer;
   gain:integer;  //source (Also known as PSI)
   internal_state:real;        ///TODO ***Maybe internal value should be replaced with the inputdata
   lambda:integer; // source
   output_before_veto:real;
   //vetoed:real;
   output:real;
   constructor create(_id:integer;
                      _inputdata: real;
                      //_threshold:integer; //source
                      _leak:integer;  //source
                      _gain:integer;  //source
                      _internal_state:real;
                      _lambda:integer; // source
                      _output_before_veto:real;
                      //_vetoed:real;
                      _output:real);
   function toString:string;
 end;
 Tvetolines = class(TObject)
 private
 public
  output:integer; //destination
  threshold:integer; //source
  constructor create(_output:integer; _threshold:integer);
  function toString:string;
 end;

implementation

constructor Tsigmoidunit.create(_id:integer;
                   _inputdata: real;
                   //_threshold:integer; //source
                   _leak:integer; //source
                   _gain:integer;  //source
                   _internal_state:real;
                   _lambda:integer; // source
                   _output_before_veto:real;
                   //_vetoed:real; //describes amount of vetoes occuring
                   _output:real);
Begin
  self.magic_nr:=MAGIC;
  self.id:=_id;
  self.inputdata:=_inputdata;
//  self.threshold:=_threshold;
  self.leak:=_leak;
  self.gain:=_gain;
  self.internal_state:=_internal_state;
  self.lambda:=_lambda;
  self.output_before_veto:=_output_before_veto;
  //self.vetoed:=_vetoed;
  self.output:=_output;
end;

constructor TSignal.create (_id:string; //id of this entity
                            _weight: integer;
                            _source :integer;  //source from neuron number "source"
                            _destination: integer;
                            _tracked:boolean);
begin
  self.id:=_id;
  self.weight:=_weight;
  self.source:=_source;
  self.destination:=_destination;
  self.tracked := _tracked;
end;

function TSignal.toString:String;
var strbool:string;

begin
  if self.tracked = True then strbool := 'True' else strbool := 'False';
  result := 'Signal(ID '+self.id+
              ',W '+IntToStr(self.weight)+
              ',S '+IntToStr(self.source)+
              ',D '+IntToStr(self.destination)+
              ',T '+strbool+')';
end;

function Tsigmoidunit.toString:String;
begin
  result:= 'SigmoidUnit(ID '+IntToStr( self.id)+
             ',In '+FloatToStr( self.inputdata)+
             //',T '+IntToStr( self.threshold)+
             '.Lk '+IntToStr( self.leak)+
             ',Gn '+IntToStr( self.gain)+
             ',St '+FloatToStr( self.internal_state)+
             ',La '+IntToStr( self.lambda)+
             ',Ov '+FloatToStr( self.output_before_veto)+
             //',V '+FloatToStr( self.vetoed)+
             ',Ot '+FloatToStr( self.output)+')';
end;

function Tvetolines.toString:String;
begin
  result:= 'VetoLine('+IntToStr(self.threshold)+
           ','+IntToStr(self.output)+')';
end;

constructor Tvetolines.create(_output:integer; _threshold:integer);
begin
  self.output:=_output;
  self.threshold:=_threshold;
end;

end.

